#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int>> val(n+1,vector<int>(m + 1));
    cout<<1<<' ';
    for(int i = 1;i<=m;i++){
        cout<<0<<' ';
    }
    cout<<'\n';
    val[0][0] = 1;
    for(int i = 1;i<=n;i++){
        val[i][0] = 1;
        cout<<1<<' ';
        for(int j = 1;j<=m;j++){
            val[i][j] = (1ll*val[i - 1][j - 1] + val[i - 1][j])%q;
            cout<<val[i][j]<<' ';
        }
        cout<<'\n';
    }
}